/*!
 * \file __frdb_get_interval_time.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "conntrack.h"
#include "frct_comm.h"
#include <frdb_cursor.h>

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}
extern unsigned long __frdb_get_interval_time(struct timeval *p_st_start_time
        , struct timeval *p_st_end_time);

static void __case1(void)
{
    struct timeval st_time1 = {0,2};
    struct timeval st_time2 = {0,1};
    unsigned long ul_ret = 0;

//    frdb_title_value_chg(NULL, 'A', NULL);

    ul_ret = __frdb_get_interval_time(&st_time1, &st_time2);

    CU_ASSERT_EQUAL(ul_ret, 0);

    return;
}

static void __case2(void)
{
    struct timeval st_time1 = {0,2};
    struct timeval st_time2 = {0,3};
    unsigned long ul_ret = 0;

    ul_ret = __frdb_get_interval_time(&st_time1, &st_time2);

    CU_ASSERT_EQUAL(ul_ret, 1);

    return;
}

static void __case3(void)
{
    struct timeval st_time1 = {0,2};
    struct timeval st_time2 = {1,1};
    unsigned long ul_ret = 0;

    ul_ret = __frdb_get_interval_time(&st_time1, &st_time2);

    CU_ASSERT_EQUAL(ul_ret, 999999);

    return;
}

static void __case4(void)
{
    struct timeval st_time1 = {1,2};
    struct timeval st_time2 = {1,0};
    unsigned long ul_ret = 0;

    ul_ret = __frdb_get_interval_time(&st_time1, &st_time2);

    CU_ASSERT_EQUAL(ul_ret, 0);

    return;
}


int add_suite___frdb_get_interval_time(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frdb_cursor __frdb_get_interval_time()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);
    CU_add_test(pSuite, "case4", __case4);

    return FR_SUCC;
}
